﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SDF.Web.Models;

namespace SDF.Web
{
    public partial class exam_list : SDF.Web.UI.Page
    {
        public List<AuthRule> ModelList = new List<AuthRule>();
        public string Pager;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //分页
                int page = Input.Get("page", 1);
                int pagesize = 10;

                var rs = db.Page<AuthRule>(page, pagesize, "where id>0 order by id asc");
                rptList.DataSource = rs.Items;
                rptList.DataBind();
                this.Pager = Html.AdminPager(rs, "?page=__id__");
            }
        }

        protected void btnDel_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");

                if (cb.Checked)
                {
                    int id = Convert.ToInt32(cb.Text);
                    db.Delete<AuthRule>(id);
                }
            }

            Response.Redirect(Request.RawUrl);
        }
    }
}